package com.agen

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.agen.data.bean.HotKeyItem
import com.agen.data.service.MainRepository
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch

class MainViewModel : ViewModel() {
    private val repository = MainRepository()

    private val _hotKeys = MutableStateFlow<List<HotKeyItem>>(emptyList())
    val hotKeys: StateFlow<List<HotKeyItem>> = _hotKeys

    fun queryHotKeys() {
        viewModelScope.launch {
            _hotKeys.value = repository.queryHotKeys().data ?: emptyList()
        }
    }
}